home *** CD-ROM | disk | FTP | other *** search
/ Amiga Game-Power / Amiga Game-Power.iso / anwendungen / gw print / structurebrowser_v1.3 / sources / sbmenu.c < prev    next >
C/C++ Source or Header  |  1994-05-20  |  5KB  |  166 lines

  1. /*
  2.    Handles the Intuition Menu and MenuItem structures
  3. */
  4.  
  5. #include "header/sb.h"
  6.  
  7. extern int level;         /* recursion level */
  8.  
  9.  
  10. /* PrMenu
  11.  
  12.    Put up the data for a Menu structure.
  13. */
  14.  
  15. PrMenu (string, menu)
  16. char *string;
  17. struct Menu *menu;
  18. {
  19. static struct StructData structdata[] = {
  20.    { " NextMenu",     "struct Menu *",       PRPTR,      PTRSIZE },
  21.    { "-LeftEdge",     "SHORT",               PRINT,      INTSIZE },
  22.    { "-TopEdge",      "SHORT",               PRINT,      INTSIZE },
  23.    { "-Width",        "SHORT",               PRINT,      INTSIZE },
  24.    { "-Height",       "SHORT",               PRINT,      INTSIZE },
  25.    { " Flags",        "USHORT",              PRUINT,     INTSIZE },
  26.    { " MenuName",     "BYTE *",              PRSTRING,   PTRSIZE },
  27.    { " FirstItem",    "struct MenuItem *",   PRPTR,      PTRSIZE },
  28.    { "-JazzX",        "USHORT",              PRUBYTE,    INTSIZE },
  29.    { "-JazzY",        "USHORT",              PRUBYTE,    INTSIZE },
  30.    { "-BeatX",        "USHORT",              PRUBYTE,    INTSIZE },
  31.    { "-BeatY",        "USHORT",              PRUBYTE,    INTSIZE }
  32. };
  33.  
  34. static char *flagnames[16] = {
  35.    "MENUENABLED",    NULL,            NULL,             NULL,
  36.    NULL,             NULL,            NULL,             NULL,
  37.    "MIDRAWN"
  38. };
  39.  
  40. int i, sum;
  41. int choice = -1;
  42. USHORT bits;
  43.  
  44.    level++;
  45.  
  46.    while (choice)
  47.    {
  48.       sum = SetOptionText(string, structdata, (APTR)menu, DATASIZE, 0);
  49.  
  50.       switch (choice = GetChoice(DATASIZE))
  51.       {
  52.          case 1:
  53.             if (menu->NextMenu)
  54.                PrMenu("The next Menu in Intuition's list", menu->NextMenu);
  55.             break;
  56.          case 6:
  57.             FlagPrint("Flags set for this Menu", flagnames,
  58.                (ULONG)menu->Flags);
  59.             break;
  60.          case 7:
  61.             PrString("The Menu's Header", menu->MenuName);
  62.             break;
  63.          case 8:
  64.             if (menu->FirstItem)
  65.                PrMenuItem("The first MenuItem for this Menu",
  66.                      menu->FirstItem);
  67.             break;
  68.       }
  69.    }
  70.    level--;
  71. }
  72.  
  73.  
  74. PrMenuItem (string, menuitem)
  75. char *string;
  76. struct MenuItem *menuitem;
  77. {
  78. static struct StructData structdata[] = {
  79.    { " NextItem",      "struct MenuItem *",   PRPTR,     PTRSIZE },
  80.    { "-LeftEdge",      "SHORT",               PRINT,     INTSIZE },
  81.    { "-TopEdge",       "SHORT",               PRINT,     INTSIZE },
  82.    { "-Width",         "SHORT",               PRINT,     INTSIZE },
  83.    { "-Height",        "SHORT",               PRINT,     INTSIZE },
  84.    { " Flags",         "USHORT",              PRUINT,    INTSIZE },
  85.    { "-MutualExclude", "LONG",                PRLONG,    PTRSIZE },
  86.    { " ItemFill",      "APTR",                PRPTR,     PTRSIZE },
  87.    { " SelectFill",    "APTR",                PRPTR,     PTRSIZE },
  88.    { "-Command",       "BYTE",                PRBYTE,    INTSIZE },
  89.    { " SubItem",       "struct MenuItem *",   PRPTR,     PTRSIZE },
  90.    { "-NextSelect",    "USHORT",              PRUINT,    INTSIZE }
  91. };
  92.  
  93. static char *flagnames[16] = {
  94.    "CHECKIT",        "ITEMTEXT",      "COMMSEQ",        "MENUTOGGLE",
  95.    "ITEMENABLED",    NULL,            "HIGHCOMP",       "HIGHBOX",
  96.    "CHECKED",        NULL,            NULL,             NULL,
  97.    "ISDRAWN",        "HIGHITEM",      "MENUTOGGLED"
  98. };
  99.  
  100. int i, sum;
  101. int choice = -1;
  102. USHORT bits;
  103.  
  104.    level++;
  105.  
  106.    while (choice)
  107.    {
  108.       sum = SetOptionText(string, structdata, (APTR)menuitem, DATASIZE, 0);
  109.  
  110.       switch (choice = GetChoice(DATASIZE))
  111.       {
  112.          case 1:
  113.             if (menuitem->NextItem)
  114.                PrMenuItem("The next Menu in Intuition's list",
  115.                   menuitem->NextItem);
  116.             break;
  117.          case 6:
  118.             bits = menuitem->Flags;
  119.             switch ((bits & HIGHFLAGS) >> 6)
  120.             {
  121.                case 0:
  122.                   flagnames[6] = "HIGHIMAGE";
  123.                   bits |= 0x40;
  124.                   break;
  125.                case 1:
  126.                   flagnames[6] = "HIGHCOMP";
  127.                   break;
  128.                case 2:
  129.                   flagnames[7] = "HIGHBOX";
  130.                   break;
  131.                case 3:
  132.                   flagnames[7] = "HIGHNONE";
  133.                   bits ^= 0x40;
  134.                   break;
  135.             }
  136.             FlagPrint("Flags set for this MenuItem", flagnames,
  137.                (ULONG)bits);
  138.             break;
  139.          case 8:
  140.             if (menuitem->ItemFill)
  141.                if (menuitem->Flags & ITEMTEXT)
  142.                   PrIText("The IntuiText for this MenuItem",
  143.                         menuitem->ItemFill);
  144.             /* else
  145.                   PrImage("The Image structure for this MenuItem",
  146.                         menutitem->ItemFill); */
  147.             break;
  148.          case 9:
  149.             if (menuitem->SelectFill)
  150.                if (menuitem->Flags & ITEMTEXT)
  151.                   PrIText("The IntuiText for this MenuItem when highlighted",
  152.                         menuitem->ItemFill);
  153.             /* else
  154.                   PrImage("The Image structure for this MenuItem",
  155.                         menutitem->ItemFill); */
  156.             break;
  157.          case 10:
  158.             if (menuitem->SubItem)
  159.                PrMenuItem("The first SubItem for this MenuItem",
  160.                   menuitem->SubItem);
  161.             break;
  162.       }
  163.    }
  164.    level--;
  165. }
  166.